package com.banyuan;

import java.io.*;

public class WriteTest {
    public static void main(String[] args) {
        OutputStream os = null;
        Writer writer = null;
        try {
             os = new FileOutputStream("/Users/edy/Desktop/file/1.txt",true);
             // 用UTF-8编码，把字符写入进去，用什么编码存，就用什么编码取
             writer = new OutputStreamWriter(os,"UTF-8");//字符流在，是依靠字节流的

            writer.write("我是中国人");
            writer.write("我是中国人");
            writer.write("我是中国人");

            writer.flush(); //一次性把写入的东西存到文件中

        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            IOUtilis.closeQuiety(writer);
            IOUtilis.closeQuiety(os);
        }
    }
}
